﻿using System;
using System.Linq;
using System.Windows.Data;

namespace ForumsBrowser
{
    public class DoublePercentConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double d = 1;
            double.TryParse(parameter.ToString(), out d);
            if (!(value is double))
                throw new ArgumentException("wrong type!");
            return (double)value * d;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
